from django.conf import settings


# 权限初始化
def init_permission(request, current_user):
    # 登录成功后 查询该用户拥有的权限url 赛选的结果不能含有null值
    permission_queryset = current_user.roles.filter(permission__isnull=False).values("permission__url").distinct()
    permission_list = [item['permission__url'] for item in permission_queryset]

    request.session[settings.CRM_PERMISSION_SESSION_KEY] = permission_list
